﻿package com.esCore
{
	import com.esADO.*;
	import com.esComponent.TesMD5;
	
	import mx.controls.dataGridClasses.DataGridColumn;
	import mx.formatters.DateFormatter;


	public class TesCore
	{
		//核心通讯模型定义
		public var ADOConnection:TesADOConnection; //通讯类
		public var ADOLoading:TesADOLoading=new TesADOLoading();
		public var ADORequest:TesADORequest=new TesADORequest();
		public var SecurityManager:TesSecurityManager=new TesSecurityManager();
		public var Config:TesConfig=new TesConfig;



		public function TesCore(aSecurityKey:String, aAppTag:String):void
		{
			ADOConnection=new TesADOConnection(aSecurityKey);
			ADORequest.AppTag=aAppTag;
		}

		//**********************************************数据编码单元*************************************	
		public function MD5Encode(aValue:String):String
		{
			return TesMD5.encrypt(aValue + ADOConnection.FSecurityKey);
		}

		public function GetformatGridColumnDateLabel(item:Object, column:DataGridColumn):String
		{
			return SetFormatDate(item[column.dataField]);
		}

		public function GetformatGridColumnDateTimeLabel(item:Object, column:DataGridColumn):String
		{
			return SetFormatDateTime(item[column.dataField]);
		}
	
		public function SetFormatDate(aDateValue:String):String
		{
			var mDateFormat:DateFormatter=new DateFormatter();
			mDateFormat.formatString=Config.FcsDateformat;
			var mValue:String=mDateFormat.format(aDateValue);
			return (mValue.indexOf("1900/01/01") >= 0) ? "" : mValue;
		}

		public function SetFormatDateTime(aDateValue:String):String
		{
			var mDateFormat:DateFormatter=new DateFormatter();
			mDateFormat.formatString="YYYY-MM-DD L:NN A";
			return mDateFormat.format(aDateValue);
		}

	}
}